//    Copyright (C) Kherty.  All rights reserved.
namespace OpenLS.Core
{
    public static class Formats
    {
        static readonly GeneralFormat _general = new GeneralFormat();
        public static GeneralFormat General { get { return _general; } }
        public static Format Currency
        {
            get
            {
                if (currency == null)
                    currency = Format.Parse("$#,##0.00");
                return currency;
            }
        }

        private static Format _fraction;
        public static Format Fraction
        {
            get
            {
                return EnsureFormat(ref _fraction, "# ?/?");
            }
        }

        static Format currency;
        public static Format Accounting
        {
            get
            {
                if (accounting == null)
                    accounting = Format.Parse("_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)");//\\Format.Parse("_($* #,##0.00_);_($* (#,##0.00);_($* \" - \"??_);_(@_)");
                return accounting;
                //\\                return Currency;
                //\\return null;//\\ return CodeTo[accountingCodes[0]];
            }
        }
        static Format accounting;

        static Format longDate;
        public static Format LongDate
        {
            get
            {
                if (longDate == null)
                    longDate = Format.Parse(@"dddd\,\ mmmm\ dd\,\ yyyy");
                return longDate;

            }
        }


        public static Format Percent
        {
            get
            {
                if (_Percent == null)
                    _Percent = Format.Parse("0%");
                return _Percent;
            }
        }

        static Format _Percent;
        public static Format DecimalPercent
        {
            get
            {
                if (_DecimalPercent == null)
                    _DecimalPercent = Format.Parse("0.00%");
                return _DecimalPercent;
            }
        }
        static Format _DecimalPercent;

        private static Format _ShortDate;
        public static Format ShortDate
        {
            get
            {
                if (_ShortDate == null)
                    _ShortDate = Format.Parse("m/d/yyyy");
                return _ShortDate;
            }
        }

        static private Format _Scientific;
        public static Format Scientific
        {
            get
            {
                if (_Scientific == null)
                    _Scientific = Format.Parse("0.00E+00");
                return _Scientific;
            }
        }
        static Format _Text;
        public static Format Text
        {
            get
            {
                return EnsureFormat(ref _Text, "@");
            }
        }
        static Format EnsureFormat(ref Format format, string code)
        {
            if (format == null)
                format = Format.Parse(code);
            return format;
        }

        private static Format _number;
        /// <summary>
        /// Get the default number format
        /// </summary>
        public static Format Number
        {
            get
            {
                return EnsureFormat(ref _number, "0");
            }
        }

        private static Format _time;
        /// <summary>
        /// Get the default time format
        /// </summary>
        public static Format Time
        {
            get
            {
                return EnsureFormat(ref _time, "h:mm AM/PM");
            }
        }



    }
}
